const constans = require('/constans/constans.js');
const app = getApp();
const Toast = require('utils/Toast.js');
const LogUtils = require('utils/LogUtils.js');
console.log(app.requestHeader)
module.exports = {
    get: function (url, data, success) {
        wx.request({
            header: app.requestHeader,
            url: url,
            method: "GET",
            data: data,
            success: success
        })
    },
    post: function (url, data, success) {
        wx.request({
            header: app.requestHeader,
            url: url,
            method: "POST",
            data: data,
            success: success
        })
    },
    postWithLoading: function (url, data, success, msg) {
        if (!msg)
            msg = "加载中";
        Toast.loading(msg);
        wx.request({
            header: app.requestHeader,
            url: url,
            method: "POST",
            data: data,
            success: function (res) {
                Toast.hideLoading();
                Toast.toast(res);
                success(res);
            }
        })
    },
    postWithToast: function (url, data, success) {
        wx.request({
            header: app.requestHeader,
            url: url,
            method: "POST",
            data: data,
            success: function (res) {
                Toast.toast(res);
                success(res);
            }
        })
    }
};
